import java.util.Scanner;

public abstract class SystemManager {
    protected Scanner scanner;

    public SystemManager(Scanner scanner) {
        this.scanner = scanner;
    }

    public abstract void manage();

    protected int getUserChoice(int min, int max, String prompt) {
        while (true) {
            System.out.print(prompt);
            try {
                int choice = Integer.parseInt(scanner.nextLine());
                if (choice >= min && choice <= max) {
                    return choice;
                }
            } catch (NumberFormatException e) {
                System.out.println("无效输入，请重新选择!");
            }
        }
    }
}
